/*MyPhotoIndex Free Photo Organizer <www.myphotoindex.com>
  Copyright (C) <2006-2009>  <Asaf Yarkoni asaf@yarkoni.net>

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing;
using System.ComponentModel;

namespace MyPhotoIndex.Controls
{
    public class MyPhtoIndexToolStrip : ToolStrip
    {
        private Color m_firstColor = Color.FromArgb(227, 239, 255);
        private Color m_secondColor = Color.FromArgb(175, 210, 255);

        [Description("ToolStrip")]
        [Category("CView")]
        public Color FirstColor
        {
            get { return m_firstColor; }
            set { m_firstColor = value; }
        }

        [Description("second Color")]
        [Category("ToolStrip")]
        public Color SecondColor
        {
            get { return m_secondColor; }
            set { m_secondColor = value; }
        }

        public MyPhtoIndexToolStrip()
        {
            base.GripStyle = ToolStripGripStyle.Hidden;
        }

        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
        }

        protected override void OnPaintBackground(PaintEventArgs pevent)
        {
            Rectangle drawRect = this.ClientRectangle;

            using (LinearGradientBrush topGradiantBrush = new LinearGradientBrush(drawRect, m_firstColor, m_secondColor, LinearGradientMode.Vertical))
            {
                pevent.Graphics.FillRectangle(topGradiantBrush, drawRect);
            }
         //   base.RenderMode = ToolStripRenderMode.ManagerRenderMode;
            Pen whitePen = Pens.White;

            Point start = new Point(drawRect.X, drawRect.Y);
            Point end = new Point(drawRect.Width, drawRect.Y);
            pevent.Graphics.DrawLine(whitePen, start, end);

            start = new Point(drawRect.X, drawRect.Y);
            end = new Point(drawRect.X, drawRect.Bottom);
            pevent.Graphics.DrawLine(whitePen, start, end);

            start = new Point(drawRect.Width - 1, drawRect.Y);
            end = new Point(drawRect.Width - 1, drawRect.Bottom);
            pevent.Graphics.DrawLine(whitePen, start, end);

            start = new Point(drawRect.X + 1, drawRect.Bottom - 1);
            end = new Point(drawRect.Width, drawRect.Bottom - 1);
            pevent.Graphics.DrawLine(whitePen, start, end);

            using (Pen borderPen = new Pen(Color.FromArgb(108, 131, 158)))
            {
                start = new Point(drawRect.X + 1, drawRect.Bottom - 2);
                end = new Point(drawRect.Width - 2, drawRect.Bottom - 2);
                pevent.Graphics.DrawLine(borderPen, start, end);
            }

            using (Pen borderPen = new Pen(Color.FromArgb(108, 131, 158)))
            {
                start = new Point(drawRect.X + 1, drawRect.Bottom - 2);
                end = new Point(drawRect.Width - 2, drawRect.Bottom - 2);
                pevent.Graphics.DrawLine(borderPen, start, end);
            }

            Color firstSideColor = Color.FromArgb(221, 235, 252);
            Color secondSideColor = Color.FromArgb(108, 131, 158);
            using (LinearGradientBrush sideBorderBrush = new LinearGradientBrush(drawRect, firstSideColor, secondSideColor, LinearGradientMode.Vertical))
            {
                using (Pen sideBorderPen = new Pen(sideBorderBrush))
                {
                    start = new Point(drawRect.X + 1, drawRect.Y + 1);
                    end = new Point(drawRect.X + 1, drawRect.Bottom - 2);
                    pevent.Graphics.DrawLine(sideBorderPen, start, end);

                    start = new Point(drawRect.Width - 2, drawRect.Y + 1);
                    end = new Point(drawRect.Width - 2, drawRect.Bottom - 2);
                    pevent.Graphics.DrawLine(sideBorderPen, start, end);
                }
            }
        }
    }

    class MyRenderer : ToolStripProfessionalRenderer
    {
        public MyRenderer()
        {
            
        }

        protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
        {
          //  base.OnRenderToolStripBorder(e);
        }

        protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
        {
            base.OnRenderToolStripBackground(e);
        }

        protected override void OnRenderToolStripPanelBackground(ToolStripPanelRenderEventArgs e)
        {
            base.OnRenderToolStripPanelBackground(e);
        }
    }
}
